import * as THREE from "three";
import { Particle } from "./Particle";

export class ForceField {
    enabled = true;
    getForce(particle: Particle) {
        return new THREE.Vector3(0, 0, 0);
    }
    update(deltaTime: number, particles: Set<Particle> | Particle[]) {
        for (let particle of particles) {
            let force = this.getForce(particle);
            particle.velocity.addScaledVector(force, deltaTime);
        }
    }
}

export class GravityForceField extends ForceField {
    gravity: THREE.Vector3;
    constructor(gravity: THREE.Vector3) {
        super();
        this.gravity = gravity;
    }
    getForce() {
        return this.gravity;
    }
}